package com.heima.admin.v1.controller;

import com.heima.admin.service.NewsAuthService;
import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.NewsAuthRequestDTO;
import com.heima.model.admin.dtos.NewsAuthResponseDTO;
import com.heima.model.user.dtos.AuthDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news_auth")
public class NewsAuthController {

    @Autowired
    NewsAuthService newsAuthService;

    /**
     * 查询自媒体文章人工审核列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public PageResult<NewsAuthResponseDTO> getList(@RequestBody NewsAuthRequestDTO dto) {
        return newsAuthService.getListByPageWithTitle(dto);
    }

    /**
     * 查询待审核文章的详细信息
     *
     * @param id
     * @return
     */
    @GetMapping("/one/{id}")
    public ResponseResult<NewsAuthResponseDTO> findByWmNewsId(@PathVariable("id") Integer id) {
        return newsAuthService.findByWmNewsId(id);
    }

    /**
     * 人工审核不通过
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody AuthDTO dto) {

        newsAuthService.authFail(dto);
        return ResponseResult.ok();
    }


    /**
     * 人工审核通过
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody AuthDTO dto) {

        newsAuthService.authPass(dto);
        return ResponseResult.ok();
    }




}
